package ebusiness.ebusiness.Controllers;

import ebusiness.ebusiness.Dao.GoodsDao.GoodQueryVO;
import ebusiness.ebusiness.Entity.Classify;
import ebusiness.ebusiness.Entity.Good;
import ebusiness.ebusiness.Entity.UserEntity.Visitor;
import ebusiness.ebusiness.Mapper.PathUtil.PagePath;
import ebusiness.ebusiness.Mapper.PathUtil.WebPath;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.Date;

@RestController
    public class GoodController {


    @RequestMapping(path = WebPath.ADDGOODCLASSIFY,method = RequestMethod.POST)
        public String AddClassifier(int id,int parentid,String name) {
            //添加商品类别
        GoodQueryVO goodQueryVO=new GoodQueryVO();
        Date date=new Date();
        try {
            goodQueryVO.addAClassify(id,parentid,name,date.toString());
        }catch (Exception e){
            return "0";
        }
            return "1";

        }
        @RequestMapping(path= WebPath.UPDATEGOODCLASSIFY,method = RequestMethod.POST)
        public String updateClassify(int id,int parentid,String name) {
            //修改类别

            GoodQueryVO goodQueryVO=new GoodQueryVO();
            Date date=new Date();
            try {
                goodQueryVO.modifyClassify(id,parentid,name,date.toString());

            }catch (Exception e){
                return "0";
            }


            return "1";
        }
@RequestMapping(path = WebPath.DELGOODCLASSIFY,method = RequestMethod.POST)
public String delClassify(int id) {
    //修改类别

    GoodQueryVO goodQueryVO=new GoodQueryVO();
    Date date=new Date();
    try {
        goodQueryVO.deleteClassify(id);

    }catch (Exception e){
        return "0";
    }


    return "1";
}
}
